Imports Clo = Enhancements.Core.Logging
Imports Ref = System.Reflection
Imports Sys = System

Namespace Enhancements.Basic
    ''' <summary>The exception that is thrown when a type derives from another.</summary>
    <Serializable(), DebuggerStepThrough()> _
    Public NotInheritable Class IsDerivedOfException
        Inherits AssertException

        Private Sub New(ByVal _objectName As System.String, ByVal _object As Sys.Type, ByVal _baseType As Sys.Type)
            MyBase.New(_objectName)
            [Object] = _object
            BaseType = _baseType
        End Sub

        Private __Object As System.Type = Nothing
        ''' <summary>Gets the derived type that caused this exception.</summary>
        Public Property [Object]() As System.Type
            Get
                Return __Object
            End Get
            Private Set(ByVal _value As System.Type)
                __Object = _value
            End Set
        End Property

        Private __BaseType As Sys.Type = Nothing
        ''' <summary>Gets the base type that caused this exception.</summary>
        Public Property BaseType() As Sys.Type
            Get
                Return __BaseType
            End Get
            Private Set(ByVal _value As Sys.Type)
                __BaseType = _value
            End Set
        End Property

        ''' <summary>Throws an exception.</summary>
        ''' <param name="_objectName">Name of the object that is causing the exception.</param>
        ''' <param name="_object">Derived type that is causing the exception.</param>
        ''' <param name="_baseType">Base type that is causing the exception.</param>
        ''' <exception cref="IsDerivedOfException"> </exception>
        Friend Shared Sub ___Throw(ByVal _objectName As System.String, ByVal _object As Sys.Type, ByVal _baseType As Sys.Type)
            Dim _exception As IsDerivedOfException = New IsDerivedOfException(_objectName, _object, _baseType)

            Throw _exception
        End Sub

    End Class
End Namespace
